﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;

namespace OrderProcess
{

    public sealed class LookupItem : CodeActivity
    {
        // 定义一个字符串类型的活动输入参数
        public InArgument<string> ItemCode { get; set; }
        public OutArgument<ItemInfo> Item { get; set; }

        // 如果活动返回值，则从 CodeActivity<TResult>
        // 派生并从 Execute 方法返回该值。
        protected override void Execute(CodeActivityContext context)
        {
            ItemInfo i = new ItemInfo();
            i.ItemCode = context.GetValue(ItemCode);
            switch(i.ItemCode){
                case "12345":
                    i.Description = "Widget";
                    i.Price = 10.0M;
                    break;
                case "12346":
                    i.Description = "Gadget";
                    i.Price = 15.0M;
                    break;
                case "12347":
                    i.Description = "Super Gadget";
                    i.Price = 25.0M;
                    break;
            }
            context.SetValue(this.Item, i);
        }
    }
}
